<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>${fns:getConfig('productName')}</title>
  <link rel="stylesheet" href="${ctxStatic}/layui-v2.5.6/layui/css/layui.css">
  <script type="text/javascript" src="${ctxStatic}/layui-v2.5.6/layui/layui.js"></script>
 
</head>


<body>

<div class="layui-fluid">
<div class="layui-card">
<div class="layui-form layui-card-header layuiadmin-card-header-auto" style="padding-top: 10px;padding-bottom: 10px;">
   
  <div class="layui-form-item">
  
  
	<!-- <label class="layui-form-label">资产名称:</label>
	<div class="layui-input-inline" style="width: 160px;">
	     <input type="text" id="name" name="name" autocomplete="off" class="layui-input">
	</div> -->
	<label class="layui-form-label">资产名称:</label>
	<div class="layui-input-inline">
		<select name="name" id="name">
	      	<option value="">请选择</option>
			<c:forEach items="${fns:getDictList('qc_investmentDecisions_name')}" var="name">
				<option value="${name.value}">${name.label}</option>
			</c:forEach>
		 </select>
	</div>
	<!-- <label class="layui-form-label">决策阶段：</label>
	<div class="layui-input-inline" style="width: 160px;">
	     <input type="text" id="phase" name="phase" autocomplete="off" class="layui-input">
	</div> -->
	
	
	<label class="layui-form-label">起止日期：</label>
	<div class="layui-input-inline" style="width: 160px;">
	     <input type="text" id="decisionDate" name="decisionDate" autocomplete="off" class="layui-input">
	</div>
	<!-- <label class="layui-form-label">至:</label> -->
	<label class="layui-form-label" style="width: 10px;">至</label>
	<div class="layui-input-inline" style="width: 160px;">
	     <input type="text" id="endDate" name="endDate" autocomplete="off" class="layui-input">
	</div>
	
	
	 <label class="layui-form-label">决策阶段：</label>
	<div class="layui-input-inline">
		<select name="phase" id="phase">
	      	<option value="">请选择</option>
			<c:forEach items="${fns:getDictList('qc_investmentDecisions_phase')}" var="phase">
				<option value="${phase.value}">${phase.label}</option>
			</c:forEach>
		 </select>
	</div>
	
	
	
	
	
	
	
	
	
	
	<!-- 
	<div class="layui-form-item">
     <div class="layui-inline">
          <label class="layui-form-label"><span class="font-color-red">*</span>附件上传
              <i class="layui-icon tips">&#xe60b;</i>
              <span class="tipsText"><i></i>仅支持上传图片、word和pdf文件类型</span>
          </label>
          <div class="layui-input-inline" style="width: 900px">
              <button type="button" class="layui-btn layui-btn-sm" id="selectFile">选择文件</button>
              <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                  <div class="layui-upload-list" id="filesArea"></div>
                  <span class="font-color-red fileWarmTips">最多上传五个附件</span>
              </blockquote>
          </div>
      </div>
 </div> -->
	
	  
     <button class="layui-btn layuiadmin-btn-comm" id="queryBtn" data-type="reload" lay-submit="" lay-filter="LAY-app-contcomm-search">
         <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>查询
    </button> 
   
  </div>
  
</div>
<div class="layui-card-body">
	<table id="table" lay-filter="test" class="demo-tree-more"></table>
</div>
</div>
</div>
<script type="text/html" id="toolbarDemo">
  <div class="layui-btn-container">
    	<button class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon layui-icon-add-1"></i>新增</button>
  </div>
</script>

<!-- 行工具栏 -->


<script type="text/html" id="barDemo">
      <a class="layui-btn layui-btn-xs layui-btn-normal btn-auth" lay-event="edit" ekper="web/disease/editDisease">编辑</a>
	  <a class="layui-btn layui-btn-xs layui-btn-normal btn-auth" lay-event="edit" ekper="web/disease/editDisease">查看</a>
      <a class="layui-btn layui-btn-xs layui-btn-danger btn-auth" lay-event="del" ekper="web/disease/deleteDisease">删除</a>
</script>
<script>
layui.use(['table','form','laydate'], function(){
  var table = layui.table;
  var form = layui.form; 
  var $ = layui.$;
  var laydate = layui.laydate;
  
  var firstDate = new Date();
   firstDate.setDate(1); //第一天
  var endDate = new Date(firstDate);
  endDate.setMonth(firstDate.getMonth()+1);
 /*   endDate.setDate(0);   */
  
  laydate.render({
		elem: '#decisionDate',
		trigger: 'click', //采用click弹出
		value: new Date(firstDate)
	});
	//日期
	laydate.render({
		elem: '#endDate',
		trigger: 'click', //采用click弹出
		value: new Date(endDate)
	}); 

  table.render({
	id: 'thisReloadId'
    ,elem: '#table'
    ,height: 650
    ,url:'${ctx}/qc/investmentDecisions/listByAjax'
     ,toolbar: '#toolbarDemo'  //开启头部工具栏，并为其绑定左侧模板
    ,defaultToolbar: ['filter', 'exports', 'print'] 
     ,title: '项目投资决策' 
    ,totalRow:true//开启合计行
    ,cols: [[
	 /*   {type:'id',title:'序号'}        */
	 
	   {field:'name', title:'项目名称',width:200}
      ,{field:'category', title:'类别',width:200}
      ,{field:'phase', title:'决策阶段',width:200} 
      ,{field:'result', title:'结果',width:200}
      /* ,{field:'Decisiondate', title:'决策日期', templet : "<div>{{d.Decisiondate ? layui.util.toDateString(d.Decisiondate, 'yyyy-MM-dd') : ''}}</div>"/* ,width:150 }
      ,{field:'enddate', title:'结束日期', templet : "<div>{{d.enddate ? layui.util.toDateString(d.enddate, 'yyyy-MM-dd') : ''}}</div>"/* ,width:150 }*/
       
       
      ,{field:'decisionDate', title:'决策日期', templet : "<div>{{d.decisionDate ? layui.util.toDateString(d.decisionDate, 'yyyy-MM-dd') : ''}}</div>",width:150}
      /*  ,{field:'oveTimeDate', title:'结束时间',width:200} */
       ,{field:'endDate', title:'登记日期', templet : "<div>{{d.endDate ? layui.util.toDateString(d.endDate, 'yyyy-MM-dd') : ''}}</div>",width:150}
      
      ,{field:'accessory', title:'附件',width:200}
      ,{fixed: 'right', title:'操作', toolbar: '#barDemo',width:350}
    ]]
    ,page: false
    ,done: function (res, curr, count) {
    	$(".layui-table th").css({"font-family":"黑体","font-size":"15","font-weight":"bold"});// 设定表格标题字体加粗
    }
  });
	  $('#queryBtn').on('click', function(){
		  var name = $('#name').val();
	      var phase = $('#phase').val();
	      var decisionDate = $('#decisionDate').val();
	      var endDate = $('#endDate').val()
	      /* alert("state value:"+rent);  */
	      //执行重载
	      table.reload('thisReloadId', {
	    	method : 'post',
	        where: { //查询条件
	        	name: name,
	        	phase:phase,
	         	decisionDate:decisionDate,
	        	endDate:endDate  
	        
	        }
	      });
	  });
  //头工具栏事件
  table.on('toolbar(test)', function(obj){
    var checkStatus = table.checkStatus(obj.config.id);
    data = checkStatus.data; //获取选中的数据
    switch(obj.event){
      case 'add':
        layer.open({
        	id:'1',
    		type: 2,
    	    title: '增加资产',
    	    btn: ['关闭'],
    	    yes: function(index, layero){
    	    	layer.close(index);
    	    },
    	    shadeClose: true,
    	    shade: false,
    	    area: ['893px', '650px'],
    	    content: '${ctx}/qc/investmentDecisions/form'
    	});
      break;
    };
  });
   
  
  //监听行工具事件
 table.on('tool(test)', function(obj){
    var data = obj.data;
    if(obj.event === 'del'){
      layer.confirm('真的删除该行么？', function(index){
        $.ajax({
            url: "${ctx}/qc/investmentDecisions/deleteById",
            type: "POST",
            dataType: "json",
            data: {
            	id : data.id
            },
            async: false,
            success: function(data){
                layer.close(index);
                //执行重载
                table.reload('thisReloadId', {
                  page: {
                    curr: 1 //重新从第 1 页开始
                  }
                }, 'data');
                layer.msg(data);
            },
            error: function(){
            	layer.msg('删除失败', {icon: 2});
            }
        });
      });
    }  else if(obj.event === 'edit'){
    	//iframe窗
    	layer.open({
    		id:'3',
    		type: 2,
    	    title: '编辑投资项目',
    	    btn: ['关闭'],
    	    yes: function(index, layero){
    	    	layer.close(index);
    	    },
    	    shadeClose: true,
    	    shade: false,
    	    area: ['893px', '650px'],
    	    content: '${ctx}/qc/investmentDecisions/form?id='+data.id
    	});
    } 
});

 function timestampToTime(timestamp) {
	    var date = new Date(timestamp);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
	    var Y = date.getFullYear() + '-';
	    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
	    var D = date.getDate();
	    return Y + M + D;
 }
});
 
 

</script>


</body>
</html>

